package com.codefish;

import java.util.Random;

/**
 * 随机打乱排序
 *
 * @author codefish
 * @version 1.0
 * @date 2022/06/27 下午 10:28
 */
public class RandomStudentQueue extends AbstractStudentQueue {

    @Override
    public void sort() {
        Random r = new Random();
        for (int pos = heightList.size() - 1; pos > 0; pos--) {
            int p = r.nextInt(pos + 1);
            int tmp = heightList.get(p);
            heightList.set(p, heightList.get(pos));
            heightList.set(pos, tmp);
        }
    }
}
